package core2.ch04database;
import java.sql.*;

public class ConnMssql {
	public static void main(String[] args) {
//		String name = "123";
//		String password = "123";
//		String e_mail = "123@163.com";
//		String telephone = "027-8658685";
//		String address = "wust";

		try {
			String query = "select * from customer_info";

			String sDBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			Class.forName(sDBDriver);

			String sConnStr = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Web";
//			String username = "sa";
//			String pwd = "";
			Connection connWeb = DriverManager.getConnection(sConnStr,"sa", "sa");
			Statement stmt = connWeb.createStatement();
			ResultSet rs = stmt.executeQuery(query);
			
			while (rs.next()) {
				rs.getString("name"+" password");
				System.out.println("Name: "+rs.getString("name")+" Password: "+rs.getString("password"));
			}
			
			rs.close();
			
		} catch (Exception ex) {
			ex.printStackTrace();

		}
	}
}
